1. Field of the Invention
The present invention relates to an improved data processing system and, in particular, to a method and apparatus for optimizing performance in a data processing system. Still more particularly, the present invention provides a method and apparatus for a software program development tool for enhancing performance of a software program through software profiling.
2. Description of Related Art
Effective management and enhancement of data processing systems requires knowing how and when various system resources are being used. In analyzing and enhancing performance of a data processing system and the applications executing within the data processing system, it is helpful to know which software modules within a data processing system are using system resources. Performance tools are used to monitor and examine a data processing system to determine resource consumption as various software applications are executing within the data processing system. For example, a performance tool may identify the most frequently executed modules and instructions in a data processing system, may identify those modules which allocate the largest amount of memory, or may identify those modules which perform the most I/O requests. Hardware-based performance tools may be built into the system or added at a later point in time. Software performance tools also are useful in data processing systems, especially in personal computer systems, which typically do not contain any built-in hardware performance tools.
In order to improve performance of program code, it is often necessary to determine how time is spent by the processor in executing code, such efforts being commonly known in the computer processing arts as locating xe2x80x9chot spots.xe2x80x9d Ideally, one would like to isolate such hot spots at various levels of granularity in order to focus attention on code which would most benefit from improvements.
For example, isolating such hot spots to the instruction level permits compiler developers to find significant areas of suboptimal code generation at which they may thus focus their efforts to improve code generation efficiency. Another potential use of instruction level detail is to provide guidance to the designer of future systems. Such designers employ profiling tools to find characteristic code sequences and/or single instructions that require optimization for the available software for a given type of hardware.
Most software engineers are more concerned about the. efficiency of applications at higher levels of granularity, such as the source code statement level or source code module level. For example, if a software engineer can determine that a particular module requires significant amounts of time to execute, the software engineer can make an effort to increase the performance of that particular module. In addition, if a software engineer can determine that a particular module is sometimes invoked unnecessarily, then the software engineer can rewrite other portions of code to eliminate unnecessary module executions.
However, an engineer tends to analyze a system for familiar issues, and if a particular type of problem is unknown to an engineer, then some problems may remain undetected. A potential source of performance problems that tends to be overlooked by many software engineers is the cross-language interface or boundary that is present in any application or application environment that has been written using multiple languages. An application can suffer significant performance losses due to poor use of the interface. It would be helpful for software engineers to have appropriate tools to detect and remedy this particular problem by identifying inefficient, cross-language interface, coding constructs so that an application developer can transform them to more efficient constructs.
Various software performance tools are available to professional software developers. One known software performance tool is a trace tool. A trace tool may use more than one technique to provide trace information that indicates execution flows for an executing program. One technique keeps track of particular sequences of instructions by logging certain events as they occur, so-called event-based profiling technique. For example, a trace tool may log every entry and corresponding exit into and from a module, subroutine, method, function, or system component. Typically, a time-stamped record is produced for each such event. Corresponding pairs of records similar to entry-exit records may also be used to trace execution of arbitrary code segments, starting and completing I/O or data transmission, and for many other events of interest. Output from a trace tool may be analyzed in many ways to identify a variety of performance-related issues.
Therefore, it would be advantageous to provide a manner of detecting inefficient use of a cross-language interface and identifying the locations in the source code of the inefficient coding constructs so that an application developer can transform the inefficient source code to more efficient constructs. It would be particularly advantageous to provide a detection mechanism that employs the output of a well known trace tool.
The present invention is a method, system, apparatus, or computer program product for improving the execution performance of an application in a data processing system. Instrumentation code is inserted into an application in which the instrumentation code generates trace data for method entry events and method exit events when the instrumented application is executed. The trace output data that is generated by the instrumentation code is then analyzed to detect patterns which indicate an inefficient coding construct in the application. The source code for the inefficient coding construct in the application associated with the detected pattern may be modified according to indications provided to an application developer. For example, a specific inefficient coding construct may be an inefficient use of a cross-language boundary, such as the interface between Java code and native code, in which data is inefficiently transferred across the interface through a local array in the native code. A suggested transform for efficient use of a cross-language boundary may include the use of a reference to a Java object within the native code.